package com.soul.parse;

import com.soul.net.Response;
import com.soul.net.http.HttpResponse;

import java.lang.reflect.Method;

/**
 * 响应结果处理
 */
public class ParseResponse implements Response {
    
    public Object parse(Method method, HttpResponse response) {
        if (response != null){
            Class<?> returnType = method.getReturnType();
            if (returnType == String.class){
                if (response.isStream()){
                    return new String(response.getBytes());
                }else{
                    return response.getContent();
                }
            }
        }
        return null;
    }
}
